package com.example.dialog.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager2.widget.ViewPager2;

import com.example.dialog.Adapter.HomeViewPagerAdapter;
import com.example.dialog.Adapter.MyProfileAdapter;
import com.example.dialog.R;
import com.google.android.material.appbar.AppBarLayout;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;

public class ProfileActivity extends BaseActivity {
    private ViewPager2 viewPager;
    private TabLayout tabLayout;
    private AppBarLayout appBarLayout;
    private Button editProfileButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_profile);
        viewPager = findViewById(R.id.viewPager);
        tabLayout = findViewById(R.id.tabLayout);
        appBarLayout = findViewById(R.id.appBarLayout);
        editProfileButton = findViewById(R.id.editProfileButton);

        // 设置ViewPager
        viewPager.setAdapter(new MyProfileAdapter(this));

        // 设置TabLayout
        new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> {
            tab.setText(position == 0 ? "我的" : "赞过");
        }).attach();

        // 设置默认显示"我的文章"页面
        viewPager.setCurrentItem(0, false);

        setupBottomNavigation();
        editProfile();
    }

    void editProfile(){
        editProfileButton.setOnClickListener(v->{
            startActivity(new Intent(this,ProfileEditActivity.class));
            //Log.e( "editProfile: ", "666");
        });
    }

}